import ajax from '@/utils/request'
export const login = (mobile, code) => {
  return ajax({
    method: 'POST', // 接口请求的方式
    url: '/app/v1_0/authorizations', // 接口地址
    data: {
      mobile: mobile,
      code: code
    }
  })
}
// 获取个人信息

export const getUsername = () => {
  return ajax({
    method: 'GET',
    url: '/app/v1_0/user/profile'
  })
}

/**
 * 关注用户
 * @param{*}userid 用户的id
 */
export const followUser = userId => {
  return ajax({
    method: 'POST',
    url: '/app/v1_0/user/followings',
    data: {
      target: userId
    }
  })
}

/**
 * 取消关注用户
 * @param{*}userid 用户id
 */
export const unFollowUser = userId => {
  return ajax({
    method: 'DELETE',
    url: '/app/v1_0/user/followings/' + userId
  })
}
// 获取个人信息
export const getInfo = () => {
  return ajax({
    method: 'GET',
    url: '/app/v1_0/user'
  })
}

// 修改个人信息
// name. gender,birthday
export const updateUserInfo = obj => {
  return ajax({
    method: 'PATCH',
    url: '/app/v1_0/user/profile',
    data: obj
  })
}
// 添加头像修改文件
// obj:以formdate格式保存
export const updatePhoto = obj => {
  return ajax({
    method: 'PATCH',
    url: '/app/v1_0/user/photo',
    data: obj
    // data: {
    //   photo: xxxx
    // }
  })
}
